<?php
/**
 * CreateTime: 2023/12/29 15:48
 * User:LinQ
 */

namespace App\Http\Service\System;

use App\Http\Service\BasicInterfaceService;
use App\Models\Client\ClientModel;
use App\Models\System\DataMappingModel;

class DataMappingService implements BasicInterfaceService
{

    public function getList(array $prams)
    {
        $page_size = $prams['page_size'] ?? 10;
        $filters = $prams['filters'] ?? [];
        $desc = $prams['desc'] ?? [];
        $clientModel = new DataMappingModel();
        $this->listSelectDefaultFilters($clientModel,$filters);
        if($filters){
            $this->listSelectFilters($clientModel,$filters);
        }
        $res = $clientModel->cListHasCom($clientModel,$page_size,$desc,[
            '*',
            'owner_id as owner_str'
        ]);
        // 处理数据
        $res['data'] = $this->dispose($res['data']);
        s_c_return($res,trans('message.get_list_ok',[
            'name' => trans('key.department')
        ]));
    }

    public function listSelectDefaultFilters($query,$filters){
        $query->pushFilter('status',1);
    }

    public function dispose($data): mixed
    {
        return $data;
    }

    public function listSelectFilters($query, $filters)
    {
        if(map_has_value($filters,'code')){
            $query->pushFilter('code',$filters['code'],'like');
        }
        if(map_has_value($filters,'key')){
            $query->pushFilter('key',$filters['key'],'like');
        }
    }

    public function getSelect()
    {
        
    }

    public function getSelectHasPage($prams)
    {
        
    }

    public function getInfo($id)
    {
        
    }

    public function create($data)
    {

    }

    public function fakeDelete($id)
    {

    }

    public function fakeDeleteByIds($ids)
    {
        
    }

    public function delete($id)
    {
        
    }

    public function update($data)
    {

    }
}